package club.vann.mock.biyi.acceptor;

import club.vann.mock.factory.AcceptorServiceFactory;
import club.vann.mock.kafka.AbsKafkaService;
import club.vann.mock.model.enums.StrategyAction;
import java.util.function.Consumer;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.stereotype.Service;

/** Acceptor 业务处理中心，负责所有 Acceptor 业务请求处理。 */
@Log4j2
@RequiredArgsConstructor
@Service
public abstract class AcceptorService extends AbsKafkaService {
  private final AcceptorServiceFactory acceptorServiceFactory;

  @Override
  public void register(
      String topic, Consumer<ConsumerRecord<String, byte[]>> consumerRecordConsumer) {
    super.register(topic, this::handle);
  }

  /**
   * 获取 Acceptor 业务类型。
   *
   * @return Acceptor 业务类型
   */
  public abstract StrategyAction action();

  /**
   * 处理 Acceptor 业务。
   *
   * @param consumerRecord Kafka数据
   */
  private void handle(ConsumerRecord<String, byte[]> consumerRecord) {
    byte[] value = consumerRecord.value();
  }
}
